package com.itheima.stream;

import java.util.*;
import java.util.stream.Stream;

public class Demo02 {

    public static void main(String[] args) {
       // listStream();
        //setStream();
        //mapStream();
        //arrayStream();
        Stream.of("关晓彤", "鹿晗", "马蓉", "宝强").forEach(s -> System.out.println(s));
    }

    private static void arrayStream() {
        int[] arr= {1,2,3,4,5};
        Arrays.stream(arr).forEach(i-> System.out.println(i));
    }

    private static void mapStream() {
        HashMap<String, String> map = new HashMap<>(Map.of("关晓彤", "鹿晗", "马蓉", "宝强"));
        // map.keySet().stream().forEach(s-> System.out.println(s+"===="+map.get(s)));
        map.entrySet().stream().forEach(s->{
            System.out.println(s.getKey()+"==="+s.getValue());
        });
    }

    private static void setStream() {
        HashSet<String> set = new HashSet<>(Set.of("a","v","b"));
        //Set 不可重复 of中不能有重复元素
        set.stream().forEach(s-> System.out.println(s));
    }

    private static void listStream() {
        //创建list
        ArrayList<String> list = new ArrayList<>(List.of("鹿晗","鹿晗","鹿晗","鹿晗","鹿晗"));
        list.stream().forEach(s-> System.out.println(s));
    }
}
